<?php
namespace app\backstage\controller;
use think\Controller;
use think\Db;
use think\facade\Request;

class BookStatistics extends Controller
{
    protected $middleware = [
        'VerifyJwt' => ['except' => []],
        'VerifyPower' => ['except' => []],
    ];

    //书籍推荐统计
    public function recom()
    {
        $agentId = request()->_role->alias == 'agent' ? request()->_user->id : 0;
        $Account = \think\facade\App::model('Account', 'logic');
        $channels = $Account->getChannels($agentId);

        $this->assign('channels',$channels);
        $this->assign('role_name',request()->_role->alias);
        return $this->fetch();
    }

    //书籍推荐统计数据列表
    public function recom_data()
    {
        $params = Request::param('', '', 'strip_tags');
        $BookRecom = \think\facade\App::model('BookRecom', 'logic');
        $result = $BookRecom->getList($params);

        if ($result['count'] > 0) {
            return ['code' => 1, 'msg' => '数据获取成功', 'count' => $result['count'], 'data' => $result['list'],'summary'=>$result['summary']];
        }

        return ['code' => 0, 'msg' => '暂无数据', 'count' => $result['count'], 'data' => $result['list'],'summary'=>$result['summary']];
    }

}